package com.example.demo.web;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.entity.Order;
import com.example.demo.feign.AccountClient;
import com.example.demo.service.IOrderService;

import io.seata.core.context.RootContext;
import io.seata.spring.annotation.GlobalTransactional;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author renshuai
 * @since 2020-04-02
 */
@RestController
public class OrderController {
	
private static Logger log = LoggerFactory.getLogger(OrderController.class);
	
	@Autowired
	private IOrderService orderService;
	
	@Autowired
	private AccountClient accountClient;
	
	@ApiOperation("根据id查询用户的接口")
    @ApiImplicitParam(name = "id", value = "用户id", defaultValue = "1", required = true)
	@GetMapping("/test")
	@ResponseBody
	@GlobalTransactional
	public String test(@RequestParam("id")Long id) {
		log.info("Assign Service Begin ... xid: " + RootContext.getXID() + "\n");
		Order order = new Order();
		order.setId(id);
		order.setCount(1000);
		orderService.updateOrder(order);
		
//		accountClient.update();
		return "ok";
	}

}

